package com.wind.trademark.file.controller;


import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wind.trademark.base.vo.NodeVo;
import com.wind.trademark.common.vo.PageBean;
import com.wind.trademark.common.vo.PageParam;
import com.wind.trademark.file.model.FiFile;
import com.wind.trademark.file.service.FileService;
import com.wind.trademark.file.vo.FileVo;

@Controller
public class FileController {
	@Autowired
	private FileService  fileService ;

	private static final Log log = LogFactory.getLog(FileController.class);

	@RequestMapping
	public @ResponseBody  FiFile loadFifile(Long id){
		return fileService.loadFiFile(id);
	}

	@RequestMapping
	public @ResponseBody
	FiFile saveOrUpdateFile(FiFile fiFile) {
		return fileService.saveOrUpdateFile(fiFile);

	}
	@RequestMapping
	public @ResponseBody
	PageBean queryFile(PageParam pageParam,
			@RequestParam Map<String, Object> params) {

		PageBean pageBean = fileService.queryFile(pageParam, params);
		return pageBean;
	}
	@RequestMapping
	public @ResponseBody  List<NodeVo> loadAllFilelyFile() {
		NodeVo nodeVo= fileService.getRootFileNode();
		return nodeVo.getChildren();
	}
	@RequestMapping
	public @ResponseBody  List<FileVo> queryFileVoByFileId(@RequestParam(required=true)Long fileId) {
		List<FileVo> fileVoes= fileService.queryFileVoByFileId(fileId);
		return fileVoes;
	}
	@RequestMapping
	public @ResponseBody
	Long[] deleteFiles(Long[] ids) {
		fileService.deleteFiles(Arrays.asList(ids));
		 return ids;
	}

}
